{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys \n",
    "sys.path.append('../scripts/')\n",
    "from kf import *   #誤差楕円を描くのに利用"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "def make_ax(): #axisの準備\n",
    "    fig = plt.figure(figsize=(4,4))\n",
    "    ax = fig.add_subplot(111)\n",
    "    ax.set_aspect('equal')\n",
    "    ax.set_xlim(-5,5)                  \n",
    "    ax.set_ylim(-5,5) \n",
    "    ax.set_xlabel(\"X\",fontsize=10) \n",
    "    ax.set_ylabel(\"Y\",fontsize=10)  \n",
    "    return ax\n",
    "\n",
    "def draw_trajectory(xs, ax): #軌跡の描画\n",
    "    poses = [xs[s] for s in range(len(xs))]\n",
    "    ax.scatter([e[0] for e in poses], [e[1] for e in poses], s=5, marker=\".\", color=\"black\")\n",
    "    ax.plot([e[0] for e in poses], [e[1] for e in poses], linewidth=0.5, color=\"black\")\n",
    "    \n",
    "def draw_observations(xs, zlist, ax): #センサ値の描画\n",
    "    for s in range(len(xs)):\n",
    "        if s not in zlist:\n",
    "            continue\n",
    "            \n",
    "        for obs in zlist[s]:\n",
    "            x, y, theta = xs[s]\n",
    "            ell, phi = obs[1][0], obs[1][1]\n",
    "            mx = x + ell*math.cos(theta + phi)\n",
    "            my = y + ell*math.sin(theta + phi)\n",
    "            ax.plot([x,mx], [y,my], color=\"pink\", alpha=0.5)\n",
    "            \n",
    "def draw_edges(edges, ax): ###graphbasedslam2draw\n",
    "    for e in edges:\n",
    "        ax.plot([e.x1[0], e.x2[0]], [e.x1[1] ,e.x2[1]], color=\"red\", alpha=0.5)\n",
    "\n",
    "def draw(xs, zlist, edges): #引数追加\n",
    "    ax = make_ax()\n",
    "    draw_observations(xs, zlist, ax)\n",
    "    draw_trajectory(xs, ax)\n",
    "    draw_edges(edges, ax) #追加\n",
    "    plt.show()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_data():#データの読み込み\n",
    "    hat_xs = {}     #軌跡のデータ（ステップ数をキーにして姿勢を保存）\n",
    "    zlist = {} #センサ値のデータ（ステップ数をキーにして、さらにその中にランドマークのIDとセンサ値をタプルで保存）\n",
    "\n",
    "    with open(\"log.txt\") as f:\n",
    "        for line in f.readlines():\n",
    "            tmp = line.rstrip().split()\n",
    "\n",
    "            step = int(tmp[1])\n",
    "            if tmp[0] == \"x\": #姿勢のレコードの場合\n",
    "                hat_xs[step] = np.array([float(tmp[2]), float(tmp[3]), float(tmp[4])]).T\n",
    "            elif tmp[0] == \"z\": #センサ値のレコードの場合\n",
    "                if step not in zlist:  #まだ辞書が空の時は空の辞書を作る\n",
    "                    zlist[step] = []\n",
    "                zlist[step].append((int(tmp[2]), np.array([float(tmp[3]), float(tmp[4]), float(tmp[5])]).T))\n",
    "                \n",
    "        return hat_xs, zlist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "class ObsEdge: ###graphbasedslam3errorfunc\n",
    "    def __init__(self, t1, t2, z1, z2, xs):\n",
    "        assert z1[0] == z2[0] \n",
    "\n",
    "        self.t1, self.t2 = t1, t2  \n",
    "        self.x1, self.x2 = xs[t1], xs[t2]\n",
    "        self.z1, self.z2 = z1[1], z2[1]\n",
    "        \n",
    "        s1 = math.sin(self.x1[2] + self.z1[1])   #ここから以下追加\n",
    "        c1 = math.cos(self.x1[2] + self.z1[1])\n",
    "        s2 = math.sin(self.x2[2] + self.z2[1])\n",
    "        c2 = math.cos(self.x2[2] + self.z2[1])\n",
    "        \n",
    "        ##残差の計算##\n",
    "        hat_e = self.x2 - self.x1 + np.array([\n",
    "            self.z2[0]*c2 - self.z1[0]*c1, \n",
    "            self.z2[0]*s2 - self.z1[0]*s1,\n",
    "            self.z2[1] - self.z2[2] - self.z1[1] + self.z1[2]\n",
    "        ])\n",
    "        while hat_e[2] >= math.pi: hat_e[2] -= math.pi*2\n",
    "        while hat_e[2] <  -math.pi: hat_e[2] += math.pi*2\n",
    "            \n",
    "        print(hat_e)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "import itertools\n",
    "def make_edges(hat_xs, zlist):\n",
    "    landmark_keys_zlist = {} #ランドマークのIDをキーにして観測された時刻とセンサ値を記録\n",
    "\n",
    "    for step in zlist:           #キーを時刻からランドマークのIDへ\n",
    "        for z in zlist[step]:\n",
    "            landmark_id = z[0]\n",
    "            if landmark_id not in landmark_keys_zlist: \n",
    "                landmark_keys_zlist[landmark_id] = []\n",
    "\n",
    "            landmark_keys_zlist[landmark_id].append((step, z))\n",
    "    \n",
    "    edges = []\n",
    "    for landmark_id in landmark_keys_zlist:\n",
    "        step_pairs = list(itertools.combinations(landmark_keys_zlist[landmark_id], 2)) #時刻のペアを作成\n",
    "        edges += [ObsEdge(xz1[0], xz2[0], xz1[1], xz2[1], hat_xs) for xz1, xz2 in step_pairs]\n",
    "        \n",
    "    return edges"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[ 0.02511196 -0.24893675 -0.18176003]\n",
      "[-1.86734452 -0.50071666 -1.00954784]\n",
      "[-2.21119867 -0.67744121 -1.13669096]\n",
      "[-2.49283301 -0.27634946 -1.14376233]\n",
      "[-2.41055235 -0.43091596 -1.12516874]\n",
      "[-2.77887803 -0.09136868 -1.12979016]\n",
      "[-2.86859036 -0.2039436  -1.23315387]\n",
      "[-2.80337278 -0.39227795 -1.20963367]\n",
      "[-4.43485467  1.08929144 -2.09952131]\n",
      "[-4.12356027  1.70342303 -2.09724255]\n",
      "[-4.42419982  1.57500114 -2.18560305]\n",
      "[-4.5412252   1.91264656 -2.28065115]\n",
      "[-4.43004201  2.18025167 -2.28617904]\n",
      "[-4.66037152  1.97596375 -2.38302724]\n",
      "[-3.52036411  3.39467824  3.0333793 ]\n",
      "[-4.49206188  3.38540497  3.0638568 ]\n",
      "[-3.67337538  3.48785591  3.00788545]\n",
      "[-3.54991785  3.62916532  2.98717053]\n",
      "[-3.72266166  3.53179157  2.98537189]\n",
      "[-3.80519064  3.62719056  2.84229077]\n",
      "[-1.89245649 -0.25177991 -0.82778782]\n",
      "[-2.23631063 -0.42850446 -0.95493094]\n",
      "[-2.51794497 -0.02741271 -0.9620023 ]\n",
      "[-2.43566431 -0.18197921 -0.94340872]\n",
      "[-2.80398999  0.15756807 -0.94803013]\n",
      "[-2.89370232  0.04499315 -1.05139384]\n",
      "[-2.82848474 -0.1433412  -1.02787365]\n",
      "[-4.45996663  1.33822819 -1.91776128]\n",
      "[-4.14867224  1.95235978 -1.91548252]\n",
      "[-4.44931178  1.82393789 -2.00384302]\n",
      "[-4.56633716  2.16158331 -2.09889112]\n",
      "[-4.45515397  2.42918842 -2.10441902]\n",
      "[-4.68548348  2.2249005  -2.20126721]\n",
      "[-3.54547608  3.64361499 -3.06804598]\n",
      "[-4.51717384  3.63434172 -3.03756848]\n",
      "[-3.69848735  3.73679267 -3.09353983]\n",
      "[-3.57502981  3.87810207 -3.11425476]\n",
      "[-3.74777362  3.78072833 -3.11605339]\n",
      "[-3.8303026   3.87612731  3.0240508 ]\n",
      "[-0.34385414 -0.17672455 -0.12714312]\n",
      "[-0.62548848  0.2243672  -0.13421449]\n",
      "[-0.54320782  0.0698007  -0.1156209 ]\n",
      "[-0.9115335   0.40934798 -0.12024232]\n",
      "[-1.00124584  0.29677306 -0.22360603]\n",
      "[-0.93602825  0.10843871 -0.20008583]\n",
      "[-2.56751014  1.5900081  -1.08997346]\n",
      "[-2.25621575  2.20413969 -1.08769471]\n",
      "[-2.55685529  2.0757178  -1.17605521]\n",
      "[-2.67388068  2.41336322 -1.27110331]\n",
      "[-2.56269749  2.68096833 -1.2766312 ]\n",
      "[-2.79302699  2.47668041 -1.3734794 ]\n",
      "[-1.65301959  3.8953949  -2.24025816]\n",
      "[-2.62471735  3.88612163 -2.20978066]\n",
      "[-1.80603086  3.98857257 -2.26575201]\n",
      "[-1.68257332  4.12988198 -2.28646694]\n",
      "[-1.85531713  4.03250823 -2.28826558]\n",
      "[-1.93784611  4.12790722 -2.43134669]\n",
      "[-0.28163434  0.40109176 -0.00707137]\n",
      "[-0.19935368  0.24652525  0.01152222]\n",
      "[-0.56767936  0.58607253  0.0069008 ]\n",
      "[-0.65739169  0.47349761 -0.09646291]\n",
      "[-0.59217411  0.28516327 -0.07294271]\n",
      "[-2.223656    1.76673265 -0.96283034]\n",
      "[-1.91236161  2.38086424 -0.96055159]\n",
      "[-2.21300115  2.25244235 -1.04891209]\n",
      "[-2.33002653  2.59008778 -1.14396019]\n",
      "[-2.21884334  2.85769288 -1.14948808]\n",
      "[-2.44917285  2.65340496 -1.24633628]\n",
      "[-1.30916545  4.07211945 -2.11311505]\n",
      "[-2.28086321  4.06284619 -2.08263754]\n",
      "[-1.46217672  4.16529713 -2.13860889]\n",
      "[-1.33871918  4.30660654 -2.15932382]\n",
      "[-1.51146299  4.20923279 -2.16112246]\n",
      "[-1.59399197  4.30463178 -2.30420357]\n",
      "[ 0.08228066 -0.1545665   0.01859359]\n",
      "[-0.28604502  0.18498077  0.01397217]\n",
      "[-0.37575736  0.07240585 -0.08939154]\n",
      "[-0.31053977 -0.11592849 -0.06587134]\n",
      "[-1.94202166  1.36564089 -0.95575898]\n",
      "[-1.63072727  1.97977249 -0.95348022]\n",
      "[-1.93136681  1.85135059 -1.04184072]\n",
      "[-2.04839219  2.18899602 -1.13688882]\n",
      "[-1.937209    2.45660113 -1.14241671]\n",
      "[-2.16753851  2.2523132  -1.23926491]\n",
      "[-1.02753111  3.67102769 -2.10604368]\n",
      "[-1.99922887  3.66175443 -2.07556617]\n",
      "[-1.18054238  3.76420537 -2.13153753]\n",
      "[-1.05708484  3.90551478 -2.15225245]\n",
      "[-1.22982865  3.80814103 -2.15405109]\n",
      "[-1.31235763  3.90354002 -2.2971322 ]\n",
      "[-0.36832568  0.33954728 -0.00462142]\n",
      "[-0.45803802  0.22697236 -0.10798512]\n",
      "[-0.39282043  0.03863802 -0.08446493]\n",
      "[-2.02430232  1.5202074  -0.97435256]\n",
      "[-1.71300793  2.13433899 -0.97207381]\n",
      "[-2.01364747  2.0059171  -1.0604343 ]\n",
      "[-2.13067285  2.34356252 -1.1554824 ]\n",
      "[-2.01948966  2.61116763 -1.1610103 ]\n",
      "[-2.24981917  2.40687971 -1.25785849]\n",
      "[-1.10981177  3.8255942  -2.12463726]\n",
      "[-2.08150953  3.81632093 -2.09415976]\n",
      "[-1.26282304  3.91877188 -2.15013111]\n",
      "[-1.1393655   4.06008129 -2.17084604]\n",
      "[-1.31210931  3.96270754 -2.17264467]\n",
      "[-1.39463829  4.05810652 -2.31572579]\n",
      "[-0.08971233 -0.11257492 -0.10336371]\n",
      "[-0.02449475 -0.30090926 -0.07984351]\n",
      "[-1.65597664  1.18066012 -0.96973115]\n",
      "[-1.34468225  1.79479171 -0.96745239]\n",
      "[-1.64532179  1.66636982 -1.05581289]\n",
      "[-1.76234717  2.00401525 -1.15086099]\n",
      "[-1.65116398  2.27162035 -1.15638888]\n",
      "[-1.88149349  2.06733243 -1.25323708]\n",
      "[-0.74148609  3.48604692 -2.12001585]\n",
      "[-1.71318385  3.47677365 -2.08953834]\n",
      "[-0.89449736  3.5792246  -2.14550969]\n",
      "[-0.77103982  3.72053401 -2.16622462]\n",
      "[-0.94378363  3.62316026 -2.16802326]\n",
      "[-1.02631261  3.71855925 -2.31110437]\n",
      "[ 0.06521759 -0.18833434  0.0235202 ]\n",
      "[-1.5662643   1.29323504 -0.86636744]\n",
      "[-1.25496991  1.90736663 -0.86408868]\n",
      "[-1.55560945  1.77894474 -0.95244918]\n",
      "[-1.67263484  2.11659016 -1.04749728]\n",
      "[-1.56145165  2.38419527 -1.05302518]\n",
      "[-1.79178116  2.17990735 -1.14987337]\n",
      "[-0.65177375  3.59862184 -2.01665214]\n",
      "[-1.62347151  3.58934857 -1.98617464]\n",
      "[-0.80478502  3.69179952 -2.04214599]\n",
      "[-0.68132748  3.83310893 -2.06286091]\n",
      "[-0.85407129  3.73573518 -2.06465955]\n",
      "[-0.93660027  3.83113416 -2.20774067]\n",
      "[-1.63148189  1.48156938 -0.88988763]\n",
      "[-1.3201875   2.09570097 -0.88760888]\n",
      "[-1.62082704  1.96727908 -0.97596938]\n",
      "[-1.73785242  2.30492451 -1.07101748]\n",
      "[-1.62666924  2.57252961 -1.07654537]\n",
      "[-1.85699874  2.36824169 -1.17339357]\n",
      "[-0.71699134  3.78695618 -2.04017233]\n",
      "[-1.6886891   3.77768292 -2.00969483]\n",
      "[-0.87000261  3.88013386 -2.06566618]\n",
      "[-0.74654507  4.02144327 -2.08638111]\n",
      "[-0.91928888  3.92406952 -2.08817975]\n",
      "[-1.00181786  4.01946851 -2.23126086]\n",
      "[0.31129439 0.61413159 0.00227876]\n",
      "[ 0.01065485  0.4857097  -0.08608174]\n",
      "[-0.10637053  0.82335513 -0.18112984]\n",
      "[ 0.00481266  1.09096023 -0.18665774]\n",
      "[-0.22551685  0.88667231 -0.28350593]\n",
      "[ 0.91449055  2.3053868  -1.1502847 ]\n",
      "[-0.05720721  2.29611353 -1.1198072 ]\n",
      "[ 0.76147928  2.39856448 -1.17577855]\n",
      "[ 0.88493682  2.53987389 -1.19649347]\n",
      "[ 0.71219301  2.44250014 -1.19829211]\n",
      "[ 0.62966403  2.53789913 -1.34137323]\n",
      "[-0.30063954 -0.12842189 -0.0883605 ]\n",
      "[-0.41766493  0.20922353 -0.1834086 ]\n",
      "[-0.30648174  0.47682864 -0.18893649]\n",
      "[-0.53681124  0.27254072 -0.28578469]\n",
      "[ 0.60319616  1.69125521 -1.15256346]\n",
      "[-0.3685016   1.68198194 -1.12208595]\n",
      "[ 0.45018489  1.78443289 -1.1780573 ]\n",
      "[ 0.57364243  1.9257423  -1.19877223]\n",
      "[ 0.40089862  1.82836855 -1.20057087]\n",
      "[ 0.31836964  1.92376753 -1.34365198]\n",
      "[-0.11702538  0.33764542 -0.0950481 ]\n",
      "[-0.00584219  0.60525053 -0.10057599]\n",
      "[-0.2361717   0.40096261 -0.19742419]\n",
      "[ 0.9038357   1.8196771  -1.06420296]\n",
      "[-0.06786206  1.81040383 -1.03372546]\n",
      "[ 0.75082443  1.91285478 -1.08969681]\n",
      "[ 0.87428197  2.05416419 -1.11041173]\n",
      "[ 0.70153816  1.95679044 -1.11221037]\n",
      "[ 0.61900918  2.05218942 -1.25529148]\n",
      "[ 0.11118319  0.26760511 -0.00552789]\n",
      "[-0.11914632  0.06331719 -0.10237609]\n",
      "[ 1.02086109  1.48203168 -0.96915486]\n",
      "[ 0.04916332  1.47275841 -0.93867736]\n",
      "[ 0.86784982  1.57520935 -0.99464871]\n",
      "[ 0.99130735  1.71651876 -1.01536363]\n",
      "[ 0.81856354  1.61914501 -1.01716227]\n",
      "[ 0.73603456  1.714544   -1.16024338]\n",
      "[-0.23032951 -0.20428792 -0.0968482 ]\n",
      "[ 0.9096779   1.21442657 -0.96362696]\n",
      "[-0.06201987  1.2051533  -0.93314946]\n",
      "[ 0.75666663  1.30760425 -0.98912081]\n",
      "[ 0.88012417  1.44891365 -1.00983574]\n",
      "[ 0.70738035  1.35153991 -1.01163437]\n",
      "[ 0.62485137  1.44693889 -1.15471549]\n",
      "[ 1.1400074   1.41871449 -0.86677877]\n",
      "[ 0.16830964  1.40944122 -0.83630126]\n",
      "[ 0.98699613  1.51189217 -0.89227262]\n",
      "[ 1.11045367  1.65320158 -0.91298754]\n",
      "[ 0.93770986  1.55582783 -0.91478618]\n",
      "[ 0.85518088  1.65122681 -1.05786729]\n",
      "[-0.97169776 -0.00927327  0.0304775 ]\n",
      "[-0.15301127  0.09317768 -0.02549385]\n",
      "[-0.02955373  0.23448709 -0.04620877]\n",
      "[-0.20229754  0.13711334 -0.04800741]\n",
      "[-0.28482652  0.23251232 -0.19108853]\n",
      "[ 0.81868649  0.10245094 -0.05597135]\n",
      "[ 0.94214403  0.24376035 -0.07668628]\n",
      "[ 0.76940022  0.1463866  -0.07848491]\n",
      "[ 0.68687124  0.24178559 -0.22156603]\n",
      "[ 0.12345754  0.14130941 -0.02071493]\n",
      "[-0.04928627  0.04393566 -0.02251356]\n",
      "[-0.13181525  0.13933465 -0.16559468]\n",
      "[-0.17274381 -0.09737375 -0.00179864]\n",
      "[-0.25527279 -0.00197476 -0.14487975]\n",
      "[-0.08252898  0.09539899 -0.14308112]\n",
      "[-0.02242    -0.40566177 -0.02814164]\n",
      "[ 0.23275112 -0.2036856  -0.15589119]\n",
      "[ 0.4670812  -0.36676966 -0.172087  ]\n",
      "[ 0.54105544 -0.33562038 -0.26845963]\n",
      "[ 0.71726938 -0.42743297 -0.36234573]\n",
      "[ 1.02186278 -1.5882901  -0.95368517]\n",
      "[ 0.95777171 -1.63710251 -0.94643601]\n",
      "[ 1.12027335 -1.50033963 -0.95382308]\n",
      "[ 0.50308524 -2.26733489 -1.05036346]\n",
      "[ 0.9039016  -2.2219039  -1.18321694]\n",
      "[ 1.01647694 -2.30099656 -1.32935022]\n",
      "[ 1.04190649 -2.4357806  -1.34779127]\n",
      "[-0.863835   -4.3503011  -2.27121218]\n",
      "[-0.92458282 -4.54305327 -2.31391138]\n",
      "[-0.88644109 -4.64592323 -2.34485207]\n",
      "[-1.55062954 -4.22175004 -2.383239  ]\n",
      "[-1.41648346 -4.54814639 -2.46916752]\n",
      "[-1.5645122  -4.56701378 -2.50545706]\n",
      "[ 0.25517112  0.20197617 -0.12774955]\n",
      "[ 0.4895012   0.03889211 -0.14394536]\n",
      "[ 0.56347544  0.07004139 -0.240318  ]\n",
      "[ 0.73968938 -0.0217712  -0.33420409]\n",
      "[ 1.04428278 -1.18262833 -0.92554353]\n",
      "[ 0.98019171 -1.23144074 -0.91829437]\n",
      "[ 1.14269335 -1.09467786 -0.92568145]\n",
      "[ 0.52550524 -1.86167313 -1.02222182]\n",
      "[ 0.9263216  -1.81624213 -1.15507531]\n",
      "[ 1.03889694 -1.89533479 -1.30120858]\n",
      "[ 1.06432649 -2.03011884 -1.31964963]\n",
      "[-0.841415   -3.94463933 -2.24307054]\n",
      "[-0.90216282 -4.1373915  -2.28576974]\n",
      "[-0.86402109 -4.24026147 -2.31671044]\n",
      "[-1.52820954 -3.81608828 -2.35509736]\n",
      "[-1.39406346 -4.14248463 -2.44102589]\n",
      "[-1.5420922  -4.16135201 -2.47731543]\n",
      "[ 0.23433007 -0.16308406 -0.01619581]\n",
      "[ 0.30830432 -0.13193478 -0.11256845]\n",
      "[ 0.48451825 -0.22374737 -0.20645454]\n",
      "[ 0.78911166 -1.3846045  -0.79779398]\n",
      "[ 0.72502059 -1.43341691 -0.79054482]\n",
      "[ 0.88752223 -1.29665403 -0.7979319 ]\n",
      "[ 0.27033412 -2.0636493  -0.89447227]\n",
      "[ 0.67115048 -2.0182183  -1.02732576]\n",
      "[ 0.78372582 -2.09731096 -1.17345903]\n",
      "[ 0.80915537 -2.23209501 -1.19190008]\n",
      "[-1.09658612 -4.14661551 -2.11532099]\n",
      "[-1.15733394 -4.33936767 -2.15802019]\n",
      "[-1.11919221 -4.44223764 -2.18896089]\n",
      "[-1.78338066 -4.01806445 -2.22734781]\n",
      "[-1.64923459 -4.3444608  -2.31327634]\n",
      "[-1.79726333 -4.36332819 -2.34956588]\n",
      "[ 0.07397425  0.03114928 -0.09637264]\n",
      "[ 0.25018818 -0.06066331 -0.19025873]\n",
      "[ 0.55478158 -1.22152044 -0.78159817]\n",
      "[ 0.49069052 -1.27033285 -0.77434901]\n",
      "[ 0.65319215 -1.13356997 -0.78173609]\n",
      "[ 0.03600404 -1.90056524 -0.87827646]\n",
      "[ 0.4368204  -1.85513424 -1.01112995]\n",
      "[ 0.54939575 -1.9342269  -1.15726322]\n",
      "[ 0.57482529 -2.06901095 -1.17570427]\n",
      "[-1.33091619 -3.98353144 -2.09912518]\n",
      "[-1.39166401 -4.17628361 -2.14182438]\n",
      "[-1.35352229 -4.27915357 -2.17276508]\n",
      "[-2.01771073 -3.85498038 -2.211152  ]\n",
      "[-1.88356466 -4.18137673 -2.29708053]\n",
      "[-2.0315934  -4.20024412 -2.33337007]\n",
      "[ 0.17621393 -0.09181259 -0.0938861 ]\n",
      "[ 0.48080734 -1.25266972 -0.68522554]\n",
      "[ 0.41671627 -1.30148213 -0.67797638]\n",
      "[ 0.57921791 -1.16471925 -0.68536345]\n",
      "[-0.0379702  -1.93171451 -0.78190383]\n",
      "[ 0.36284616 -1.88628352 -0.91475731]\n",
      "[ 0.4754215  -1.96537618 -1.06089058]\n",
      "[ 0.50085105 -2.10016022 -1.07933164]\n",
      "[-1.40489044 -4.01468072 -2.00275254]\n",
      "[-1.46563826 -4.20743289 -2.04545175]\n",
      "[-1.42749653 -4.31030285 -2.07639244]\n",
      "[-2.09168498 -3.88612966 -2.11477936]\n",
      "[-1.9575389  -4.21252601 -2.20070789]\n",
      "[-2.10556765 -4.2313934  -2.23699743]\n",
      "[ 0.30459341 -1.16085713 -0.59133944]\n",
      "[ 0.24050234 -1.20966954 -0.58409028]\n",
      "[ 0.40300398 -1.07290666 -0.59147735]\n",
      "[-0.21418413 -1.83990193 -0.68801773]\n",
      "[ 0.18663223 -1.79447093 -0.82087121]\n",
      "[ 0.29920757 -1.87356359 -0.96700449]\n",
      "[ 0.32463712 -2.00834764 -0.98544554]\n",
      "[-1.58110437 -3.92286813 -1.90886644]\n",
      "[-1.64185219 -4.1156203  -1.95156565]\n",
      "[-1.60371047 -4.21849026 -1.98250634]\n",
      "[-2.26789891 -3.79431707 -2.02089327]\n",
      "[-2.13375284 -4.12071342 -2.10682179]\n",
      "[-2.28178158 -4.13958081 -2.14311133]\n",
      "[-0.06409107 -0.04881241  0.00724916]\n",
      "[ 0.09841057  0.08795047 -0.00013791]\n",
      "[-0.51877754 -0.6790448  -0.09667829]\n",
      "[-0.11796118 -0.6336138  -0.22953177]\n",
      "[-0.00538584 -0.71270646 -0.37566505]\n",
      "[ 0.02004371 -0.84749051 -0.3941061 ]\n",
      "[-1.88569778 -2.762011   -1.317527  ]\n",
      "[-1.9464456  -2.95476317 -1.36022621]\n",
      "[-1.90830387 -3.05763313 -1.3911669 ]\n",
      "[-2.57249232 -2.63345995 -1.42955383]\n",
      "[-2.43834624 -2.95985629 -1.51548235]\n",
      "[-2.58637498 -2.97872368 -1.55177189]\n",
      "[ 0.16250164  0.13676288 -0.00738707]\n",
      "[-0.45468647 -0.63023239 -0.10392745]\n",
      "[-0.05387011 -0.58480139 -0.23678093]\n",
      "[ 0.05870523 -0.66389405 -0.38291421]\n",
      "[ 0.08413478 -0.7986781  -0.40135526]\n",
      "[-1.82160671 -2.71319859 -1.32477616]\n",
      "[-1.88235453 -2.90595076 -1.36747537]\n",
      "[-1.8442128  -3.00882073 -1.39841606]\n",
      "[-2.50840125 -2.58464754 -1.43680298]\n",
      "[-2.37425518 -2.91104389 -1.52273151]\n",
      "[-2.52228392 -2.92991127 -1.55902105]\n",
      "[-0.61718811 -0.76699527 -0.09654038]\n",
      "[-0.21637175 -0.72156427 -0.22939386]\n",
      "[-0.10379641 -0.80065693 -0.37552713]\n",
      "[-0.07836686 -0.93544098 -0.39396819]\n",
      "[-1.98410835 -2.84996148 -1.31738909]\n",
      "[-2.04485617 -3.04271364 -1.3600883 ]\n",
      "[-2.00671444 -3.14558361 -1.39102899]\n",
      "[-2.67090289 -2.72141042 -1.42941591]\n",
      "[-2.53675681 -3.04780677 -1.51534444]\n",
      "[-2.68478555 -3.06667416 -1.55163398]\n",
      "[ 0.40081636  0.045431   -0.13285348]\n",
      "[ 0.5133917  -0.03366166 -0.27898676]\n",
      "[ 0.53882125 -0.16844571 -0.29742781]\n",
      "[-1.36692024 -2.08296621 -1.22084872]\n",
      "[-1.42766806 -2.27571837 -1.26354792]\n",
      "[-1.38952633 -2.37858834 -1.29448861]\n",
      "[-2.05371478 -1.95441515 -1.33287554]\n",
      "[-1.9195687  -2.2808115  -1.41880406]\n",
      "[-2.06759745 -2.29967889 -1.4550936 ]\n",
      "[ 0.11257534 -0.07909266 -0.14613327]\n",
      "[ 0.13800489 -0.21387671 -0.16457433]\n",
      "[-1.7677366  -2.1283972  -1.08799523]\n",
      "[-1.82848442 -2.32114937 -1.13069444]\n",
      "[-1.79034269 -2.42401933 -1.16163513]\n",
      "[-2.45453114 -1.99984614 -1.20002205]\n",
      "[-2.32038506 -2.32624249 -1.28595058]\n",
      "[-2.46841381 -2.34510988 -1.32224012]\n",
      "[ 0.02542955 -0.13478405 -0.01844105]\n",
      "[-1.88031194 -2.04930455 -0.94186196]\n",
      "[-1.94105976 -2.24205671 -0.98456116]\n",
      "[-1.90291803 -2.34492668 -1.01550186]\n",
      "[-2.56710648 -1.92075349 -1.05388878]\n",
      "[-2.43296041 -2.24714984 -1.13981731]\n",
      "[-2.58098915 -2.26601723 -1.17610685]\n",
      "[-1.90574149 -1.9145205  -0.9234209 ]\n",
      "[-1.96648931 -2.10727266 -0.96612011]\n",
      "[-1.92834758 -2.21014263 -0.9970608 ]\n",
      "[-2.59253603 -1.78596944 -1.03544773]\n",
      "[-2.45838995 -2.11236579 -1.12137625]\n",
      "[-2.60641869 -2.13123318 -1.15766579]\n",
      "[-0.06074782 -0.19275216 -0.0426992 ]\n",
      "[-0.02260609 -0.29562213 -0.0736399 ]\n",
      "[-0.68679454  0.12855106 -0.11202682]\n",
      "[-0.55264847 -0.19784529 -0.19795535]\n",
      "[-0.70067721 -0.21671268 -0.23424489]\n",
      "[ 0.03814173 -0.10286997 -0.03094069]\n",
      "[-0.62604672  0.32130322 -0.06932762]\n",
      "[-0.49190064 -0.00509313 -0.15525614]\n",
      "[-0.63992939 -0.02396052 -0.19154568]\n",
      "[-0.66418845  0.42417319 -0.03838692]\n",
      "[-0.53004237  0.09777684 -0.12431545]\n",
      "[-0.67807111  0.07890945 -0.16060499]\n",
      "[ 0.13414607 -0.32639635 -0.08592853]\n",
      "[-0.01388267 -0.34526374 -0.12221807]\n",
      "[-0.14802874 -0.01886739 -0.03628954]\n",
      "[ 0.17407359 -0.36487283 -0.16599979]\n",
      "[ 0.89686511 -0.1119996  -0.21047931]\n",
      "[ 0.88620079 -0.83406623 -0.24524233]\n",
      "[ 0.82412063 -3.80456631 -0.8758805 ]\n",
      "[ 1.02508613 -3.7981927  -0.879408  ]\n",
      "[ 2.17815537 -4.50785983 -1.06293694]\n",
      "[ 1.00498578 -5.24637637 -1.17014263]\n",
      "[ 1.01314115 -5.32142224 -1.20489373]\n",
      "[-4.24961389 -8.56660041 -2.36993315]\n",
      "[-4.5007545  -8.36826835 -2.29797151]\n",
      "[-4.46426568 -8.64804443 -2.31169617]\n",
      "[ 0.72279152  0.25287323 -0.04447951]\n",
      "[ 0.7121272  -0.4691934  -0.07924254]\n",
      "[ 0.65004704 -3.43969348 -0.7098807 ]\n",
      "[ 0.85101254 -3.43331986 -0.7134082 ]\n",
      "[ 2.00408178 -4.14298699 -0.89693714]\n",
      "[ 0.83091219 -4.88150353 -1.00414283]\n",
      "[ 0.83906755 -4.95654941 -1.03889393]\n",
      "[-4.42368749 -8.20172758 -2.20393336]\n",
      "[-4.67482809 -8.00339551 -2.13197171]\n",
      "[-4.63833927 -8.28317159 -2.14569637]\n",
      "[-0.01066432 -0.72206663 -0.03476302]\n",
      "[-0.07274448 -3.69256671 -0.66540119]\n",
      "[ 0.12822102 -3.68619309 -0.66892869]\n",
      "[ 1.28129026 -4.39586022 -0.85245763]\n",
      "[ 0.10812067 -5.13437676 -0.95966332]\n",
      "[ 0.11627604 -5.20942264 -0.99441442]\n",
      "[-5.146479   -8.45460081 -2.15945385]\n",
      "[-5.39761961 -8.25626874 -2.0874922 ]\n",
      "[-5.36113079 -8.53604482 -2.10121686]\n",
      "[-0.06208016 -2.97050008 -0.63063816]\n",
      "[ 0.13888534 -2.96412646 -0.63416566]\n",
      "[ 1.29195458 -3.6737936  -0.8176946 ]\n",
      "[ 0.11878499 -4.41231013 -0.92490029]\n",
      "[ 0.12694036 -4.48735601 -0.95965139]\n",
      "[-5.13581468 -7.73253418 -2.12469082]\n",
      "[-5.38695528 -7.53420211 -2.05272917]\n",
      "[-5.35046647 -7.81397819 -2.06645383]\n",
      "[ 0.2009655   0.00637361 -0.0035275 ]\n",
      "[ 1.35403474 -0.70329352 -0.18705644]\n",
      "[ 0.18086515 -1.44181006 -0.29426213]\n",
      "[ 0.18902052 -1.51685593 -0.32901323]\n",
      "[-5.07373452 -4.7620341  -1.49405266]\n",
      "[-5.32487513 -4.56370204 -1.42209101]\n",
      "[-5.28838631 -4.84347812 -1.43581567]\n",
      "[ 1.15306924 -0.70966713 -0.18352894]\n",
      "[-0.02010035 -1.44818367 -0.29073463]\n",
      "[-0.01194498 -1.52322955 -0.32548573]\n",
      "[-5.27470002 -4.76840772 -1.49052516]\n",
      "[-5.52584062 -4.57007565 -1.41856351]\n",
      "[-5.48935181 -4.84985173 -1.43228817]\n",
      "[-1.17316959 -0.73851654 -0.10720569]\n",
      "[-1.16501422 -0.81356241 -0.14195679]\n",
      "[-6.42776927 -4.05874059 -1.30699622]\n",
      "[-6.67890987 -3.86040852 -1.23503457]\n",
      "[-6.64242105 -4.1401846  -1.24875923]\n",
      "[ 0.00815537 -0.07504588 -0.0347511 ]\n",
      "[-5.25459968 -3.32022405 -1.19979053]\n",
      "[-5.50574028 -3.12189198 -1.12782888]\n",
      "[-5.46925146 -3.40166806 -1.14155354]\n",
      "[-5.26275504 -3.24517817 -1.16503943]\n",
      "[-5.51389564 -3.04684611 -1.09307778]\n",
      "[-5.47740683 -3.32662218 -1.10680244]\n",
      "[-0.2511406   0.19833207  0.07196165]\n",
      "[-0.21465179 -0.08144401  0.05823699]\n",
      "[ 0.03648882 -0.27977608 -0.01372466]\n",
      "[ 0.44838829 -0.09092712 -0.06540109]\n",
      "[ 0.7817394  -0.50703153 -0.16361184]\n",
      "[ 0.77537121 -0.3384231  -0.0787463 ]\n",
      "[ 3.47785216 -3.43873458 -0.91575053]\n",
      "[ 3.81195707 -3.57555739 -0.99132256]\n",
      "[ 3.38963586 -4.20291271 -1.12910413]\n",
      "[ 0.70558873 -9.15310044 -2.09230257]\n",
      "[ 0.8945705  -9.666753   -2.20149823]\n",
      "[ 0.25232535 -9.45689214 -2.19022818]\n",
      "[ 0.33335111 -0.41610441 -0.09821075]\n",
      "[ 0.32698292 -0.24749597 -0.0133452 ]\n",
      "[ 3.02946387 -3.34780746 -0.85034943]\n",
      "[ 3.36356878 -3.48463027 -0.92592146]\n",
      "[ 2.94124757 -4.11198559 -1.06370303]\n",
      "[ 0.25720044 -9.06217331 -2.02690147]\n",
      "[ 0.4461822  -9.57582588 -2.13609714]\n",
      "[-0.19606294 -9.36596502 -2.12482709]\n",
      "[-0.00636819  0.16860844  0.08486554]\n",
      "[ 2.69611276 -2.93170305 -0.75213869]\n",
      "[ 3.03021767 -3.06852586 -0.82771072]\n",
      "[ 2.60789646 -3.69588118 -0.96549229]\n",
      "[-0.07615067 -8.6460689  -1.92869073]\n",
      "[ 0.11283109 -9.15972147 -2.0378864 ]\n",
      "[-0.52941405 -8.94986061 -2.02661634]\n",
      "[ 2.70248095 -3.10031148 -0.83700423]\n",
      "[ 3.03658586 -3.23713429 -0.91257626]\n",
      "[ 2.61426465 -3.86448962 -1.05035783]\n",
      "[-0.06978248 -8.81467734 -2.01355627]\n",
      "[ 0.11919929 -9.32832991 -2.12275194]\n",
      "[-0.52304586 -9.11846904 -2.11148188]\n",
      "[ 0.33410491 -0.13682281 -0.07557203]\n",
      "[-0.0882163  -0.76417814 -0.2133536 ]\n",
      "[-2.77226343 -5.71436586 -1.17655204]\n",
      "[-2.58328166 -6.22801843 -1.28574771]\n",
      "[-3.22552681 -6.01815756 -1.27447765]\n",
      "[-0.42232121 -0.62735533 -0.13778157]\n",
      "[-3.10636834 -5.57754305 -1.10098001]\n",
      "[-2.91738658 -6.09119561 -1.21017568]\n",
      "[-3.55963172 -5.88133475 -1.19890562]\n",
      "[-2.68404713 -4.95018772 -0.96319844]\n",
      "[-2.49506536 -5.46384029 -1.07239411]\n",
      "[-3.13731051 -5.25397943 -1.06112405]\n",
      "[ 0.18898177 -0.51365257 -0.10919567]\n",
      "[-0.45326338 -0.3037917  -0.09792561]\n",
      "[-0.64224514  0.20986086  0.01127006]\n",
      "[ 0.44913148 -0.24460046 -0.00601201]\n",
      "[ 0.6761719  -0.0650854  -0.05180729]\n",
      "[ 0.38414918  0.20692953 -0.11583763]\n",
      "[ 0.70922696  0.35446796 -0.20549073]\n",
      "[ 0.8184445   0.5011304  -0.33476373]\n",
      "[ 0.67460118  0.43916354 -0.22255888]\n",
      "[ 2.38386719  1.85981291 -0.8999743 ]\n",
      "[ 3.06355082  1.00065834 -0.94659176]\n",
      "[ 3.17295489  1.25086117 -0.9734934 ]\n",
      "[ 3.06250525  1.51113977 -0.94740992]\n",
      "[ 3.64721041  1.12966058 -1.14723091]\n",
      "[ 3.71162778  1.25396097 -1.18712616]\n",
      "[ 5.37944316 -1.35637112 -2.06743913]\n",
      "[ 5.29404092 -2.07594392 -2.27691433]\n",
      "[ 5.57432069 -2.27101312 -2.31785978]\n",
      "[ 5.78267243 -2.3566622  -2.37479439]\n",
      "[ 5.84259287 -2.36068612 -2.3822617 ]\n",
      "[ 0.22704042  0.17951506 -0.04579528]\n",
      "[-0.06498229  0.45152999 -0.10982562]\n",
      "[ 0.26009548  0.59906842 -0.19947872]\n",
      "[ 0.36931302  0.74573086 -0.32875171]\n",
      "[ 0.2254697   0.683764   -0.21654687]\n",
      "[ 1.93473571  2.10441337 -0.89396229]\n",
      "[ 2.61441934  1.24525879 -0.94057975]\n",
      "[ 2.72382341  1.49546162 -0.96748139]\n",
      "[ 2.61337377  1.75574023 -0.9413979 ]\n",
      "[ 3.19807893  1.37426103 -1.1412189 ]\n",
      "[ 3.2624963   1.49856143 -1.18111415]\n",
      "[ 4.93031169 -1.11177066 -2.06142711]\n",
      "[ 4.84490944 -1.83134347 -2.27090232]\n",
      "[ 5.12518921 -2.02641267 -2.31184777]\n",
      "[ 5.33354095 -2.11206175 -2.36878238]\n",
      "[ 5.39346139 -2.11608567 -2.37624969]\n",
      "[-0.29202272  0.27201493 -0.06403034]\n",
      "[ 0.03305506  0.41955336 -0.15368344]\n",
      "[ 0.1422726   0.5662158  -0.28295643]\n",
      "[-0.00157072  0.50424894 -0.17075159]\n",
      "[ 1.70769528  1.92489831 -0.84816701]\n",
      "[ 2.38737891  1.06574374 -0.89478447]\n",
      "[ 2.49678299  1.31594656 -0.92168611]\n",
      "[ 2.38633335  1.57622517 -0.89560262]\n",
      "[ 2.9710385   1.19474598 -1.09542362]\n",
      "[ 3.03545588  1.31904637 -1.13531887]\n",
      "[ 4.70327126 -1.29128572 -2.01563183]\n",
      "[ 4.61786902 -2.01085852 -2.22510704]\n",
      "[ 4.89814879 -2.20592772 -2.26605249]\n",
      "[ 5.10650053 -2.29157681 -2.3229871 ]\n",
      "[ 5.16642097 -2.29560072 -2.33045441]\n",
      "[ 0.32507778  0.14753843 -0.0896531 ]\n",
      "[ 0.43429532  0.29420087 -0.21892609]\n",
      "[ 0.29045199  0.23223401 -0.10672125]\n",
      "[ 1.999718    1.65288338 -0.78413667]\n",
      "[ 2.67940163  0.79372881 -0.83075413]\n",
      "[ 2.78880571  1.04393164 -0.85765577]\n",
      "[ 2.67835607  1.30421024 -0.83157228]\n",
      "[ 3.26306122  0.92273105 -1.03139328]\n",
      "[ 3.3274786   1.04703144 -1.07128853]\n",
      "[ 4.99529398 -1.56330065 -1.95160149]\n",
      "[ 4.90989174 -2.28287345 -2.1610767 ]\n",
      "[ 5.1901715  -2.47794265 -2.20202215]\n",
      "[ 5.39852325 -2.56359173 -2.25895676]\n",
      "[ 5.45844369 -2.56761565 -2.26642407]\n",
      "[ 0.10921754  0.14666244 -0.12927299]\n",
      "[-0.03462578  0.08469558 -0.01706815]\n",
      "[ 1.67464023  1.50534495 -0.69448357]\n",
      "[ 2.35432386  0.64619038 -0.74110102]\n",
      "[ 2.46372793  0.8963932  -0.76800267]\n",
      "[ 2.35327829  1.15667181 -0.74191918]\n",
      "[ 2.93798344  0.77519262 -0.94174018]\n",
      "[ 3.00240082  0.89949301 -0.98163542]\n",
      "[ 4.6702162  -1.71083908 -1.86194839]\n",
      "[ 4.58481396 -2.43041189 -2.0714236 ]\n",
      "[ 4.86509373 -2.62548109 -2.11236905]\n",
      "[ 5.07344547 -2.71113017 -2.16930366]\n",
      "[ 5.13336591 -2.71515408 -2.17677097]\n",
      "[-0.14384332 -0.06196686  0.11220484]\n",
      "[ 1.56542268  1.35868251 -0.56521058]\n",
      "[ 2.24510631  0.49952794 -0.61182803]\n",
      "[ 2.35451039  0.74973077 -0.63872968]\n",
      "[ 2.24406075  1.01000937 -0.61264619]\n",
      "[ 2.8287659   0.62853018 -0.81246719]\n",
      "[ 2.89318328  0.75283057 -0.85236243]\n",
      "[ 4.56099866 -1.85750152 -1.7326754 ]\n",
      "[ 4.47559642 -2.57707432 -1.94215061]\n",
      "[ 4.75587619 -2.77214352 -1.98309606]\n",
      "[ 4.96422793 -2.8577926  -2.04003067]\n",
      "[ 5.02414837 -2.86181652 -2.04749798]\n",
      "[ 1.70926601  1.42064937 -0.67741542]\n",
      "[ 2.38894964  0.5614948  -0.72403288]\n",
      "[ 2.49835371  0.81169762 -0.75093452]\n",
      "[ 2.38790407  1.07197623 -0.72485103]\n",
      "[ 2.97260923  0.69049704 -0.92467203]\n",
      "[ 3.0370266   0.81479743 -0.96456728]\n",
      "[ 4.70484199 -1.79553466 -1.84488024]\n",
      "[ 4.61943974 -2.51510746 -2.05435545]\n",
      "[ 4.89971951 -2.71017666 -2.0953009 ]\n",
      "[ 5.10807125 -2.79582575 -2.15223551]\n",
      "[ 5.16799169 -2.79984966 -2.15970282]\n",
      "[ 0.67968363 -0.85915457 -0.04661746]\n",
      "[ 0.7890877  -0.60895174 -0.0735191 ]\n",
      "[ 0.67863806 -0.34867314 -0.04743562]\n",
      "[ 1.26334322 -0.73015233 -0.24725661]\n",
      "[ 1.32776059 -0.60585194 -0.28715186]\n",
      "[ 2.99557598 -3.21618403 -1.16746482]\n",
      "[ 2.91017373 -3.93575683 -1.37694003]\n",
      "[ 3.1904535  -4.13082603 -1.41788548]\n",
      "[ 3.39880524 -4.21647511 -1.47482009]\n",
      "[ 3.45872568 -4.22049903 -1.4822874 ]\n",
      "[ 0.10940407  0.25020283 -0.02690164]\n",
      "[-0.00104557  0.51048143 -0.00081816]\n",
      "[ 0.58365959  0.12900224 -0.20063915]\n",
      "[ 0.64807696  0.25330264 -0.2405344 ]\n",
      "[ 2.31589235 -2.35702945 -1.12084737]\n",
      "[ 2.2304901  -3.07660226 -1.33032257]\n",
      "[ 2.51076987 -3.27167146 -1.37126802]\n",
      "[ 2.71912161 -3.35732054 -1.42820264]\n",
      "[ 2.77904205 -3.36134446 -1.43566994]\n",
      "[-0.11044964  0.26027861  0.02608348]\n",
      "[ 0.47425552 -0.12120059 -0.17373751]\n",
      "[ 0.53867289  0.00309981 -0.21363276]\n",
      "[ 2.20648827 -2.60723228 -1.09394572]\n",
      "[ 2.12108603 -3.32680509 -1.30342093]\n",
      "[ 2.4013658  -3.52187429 -1.34436638]\n",
      "[ 2.60971754 -3.60752337 -1.40130099]\n",
      "[ 2.66963798 -3.61154729 -1.4087683 ]\n",
      "[ 0.58470516 -0.38147919 -0.199821  ]\n",
      "[ 0.64912253 -0.2571788  -0.23971624]\n",
      "[ 2.31693791 -2.86751089 -1.12002921]\n",
      "[ 2.23153567 -3.58708369 -1.32950441]\n",
      "[ 2.51181544 -3.78215289 -1.37044987]\n",
      "[ 2.72016718 -3.86780198 -1.42738448]\n",
      "[ 2.78008762 -3.87182589 -1.43485178]\n",
      "[ 0.06441737  0.1243004  -0.03989525]\n",
      "[ 1.73223276 -2.4860317  -0.92020821]\n",
      "[ 1.64683051 -3.2056045  -1.12968342]\n",
      "[ 1.92711028 -3.4006737  -1.17062887]\n",
      "[ 2.13546202 -3.48632278 -1.22756348]\n",
      "[ 2.19538246 -3.4903467  -1.23503079]\n",
      "[ 1.66781539 -2.61033209 -0.88031297]\n",
      "[ 1.58241314 -3.3299049  -1.08978817]\n",
      "[ 1.86269291 -3.5249741  -1.13073362]\n",
      "[ 2.07104465 -3.61062318 -1.18766824]\n",
      "[ 2.13096509 -3.6146471  -1.19513554]\n",
      "[-0.08540224 -0.71957281 -0.20947521]\n",
      "[ 0.19487752 -0.91464201 -0.25042066]\n",
      "[ 0.40322927 -1.00029109 -0.30735527]\n",
      "[ 0.4631497  -1.004315   -0.31482258]\n",
      "[ 0.28027977 -0.1950692  -0.04094545]\n",
      "[ 0.48863151 -0.28071828 -0.09788006]\n",
      "[ 0.54855195 -0.2847422  -0.10534737]\n",
      "[ 0.20835174 -0.08564908 -0.05693461]\n",
      "[ 0.26827218 -0.089673   -0.06440192]\n",
      "[ 0.05992044 -0.00402392 -0.00746731]\n",
      "[-0.26439477  1.08219528 -0.06510539]\n",
      "[ 0.5071054   0.73756792 -0.22489987]\n",
      "[ 3.92725237 -0.51698421 -0.79188012]\n",
      "[ 3.99430367 -0.60707198 -0.89659644]\n",
      "[ 4.25939364 -1.27074044 -0.94335464]\n",
      "[ 4.82098504 -1.13661644 -1.23080876]\n",
      "[ 6.24559384 -6.32019433 -2.20478866]\n",
      "[ 5.98979151 -6.74652695 -2.18253963]\n",
      "[ 6.64115756 -7.37976401 -2.31106083]\n",
      "[ 5.67341101 -7.86821353 -2.38848043]\n",
      "[ 0.77150016 -0.34462736 -0.15979448]\n",
      "[ 4.19164713 -1.59917949 -0.72677473]\n",
      "[ 4.25869844 -1.68926726 -0.83149104]\n",
      "[ 4.52378841 -2.35293572 -0.87824925]\n",
      "[ 5.08537981 -2.21881172 -1.16570337]\n",
      "[ 6.50998861 -7.40238962 -2.13968326]\n",
      "[ 6.25418628 -7.82872223 -2.11743423]\n",
      "[ 6.90555233 -8.46195929 -2.24595543]\n",
      "[ 5.93780578 -8.95040882 -2.32337504]\n",
      "[ 3.42014697 -1.25455213 -0.56698025]\n",
      "[ 3.48719828 -1.3446399  -0.67169656]\n",
      "[ 3.75228825 -2.00830836 -0.71845477]\n",
      "[ 4.31387965 -1.87418436 -1.00590889]\n",
      "[ 5.73848844 -7.05776226 -1.97988879]\n",
      "[ 5.48268611 -7.48409487 -1.95763975]\n",
      "[ 6.13405217 -8.11733193 -2.08616095]\n",
      "[ 5.16630562 -8.60578146 -2.16358056]\n",
      "[ 0.06705131 -0.09008777 -0.10471631]\n",
      "[ 0.33214128 -0.75375623 -0.15147452]\n",
      "[ 0.89373268 -0.61963223 -0.43892864]\n",
      "[ 2.31834147 -5.80321012 -1.41290854]\n",
      "[ 2.06253914 -6.22954274 -1.3906595 ]\n",
      "[ 2.7139052 -6.8627798 -1.5191807]\n",
      "[ 1.74615865 -7.35122932 -1.59660031]\n",
      "[ 0.26508997 -0.66366846 -0.04675821]\n",
      "[ 0.82668137 -0.52954446 -0.33421233]\n",
      "[ 2.25129017 -5.71312235 -1.30819222]\n",
      "[ 1.99548784 -6.13945497 -1.28594319]\n",
      "[ 2.64685389 -6.77269203 -1.41446439]\n",
      "[ 1.67910734 -7.26114155 -1.491884  ]\n",
      "[ 0.5615914   0.134124   -0.28745412]\n",
      "[ 1.9862002  -5.04945389 -1.26143402]\n",
      "[ 1.73039787 -5.47578651 -1.23918498]\n",
      "[ 2.38176392 -6.10902357 -1.36770618]\n",
      "[ 1.41401737 -6.59747309 -1.44512579]\n",
      "[ 1.4246088 -5.1835779 -0.9739799]\n",
      "[ 1.16880647 -5.60991051 -0.95173086]\n",
      "[ 1.82017252 -6.24314757 -1.08025206]\n",
      "[ 0.85242597 -6.7315971  -1.15767167]\n",
      "[-0.25580233 -0.42633261  0.02224903]\n",
      "[ 0.39556372 -1.05956968 -0.10627217]\n",
      "[-0.57218283 -1.5480192  -0.18369178]\n",
      "[ 0.65136605 -0.63323706 -0.1285212 ]\n",
      "[-0.3163805  -1.12168659 -0.20594081]\n",
      "[-0.96774655 -0.48844952 -0.07741961]\n"
     ]
    },
    {
     "data": {
      "application/javascript": [
       "/* Put everything inside the global mpl namespace */\n",
       "window.mpl = {};\n",
       "\n",
       "\n",
       "mpl.get_websocket_type = function() {\n",
       "    if (typeof(WebSocket) !== 'undefined') {\n",
       "        return WebSocket;\n",
       "    } else if (typeof(MozWebSocket) !== 'undefined') {\n",
       "        return MozWebSocket;\n",
       "    } else {\n",
       "        alert('Your browser does not have WebSocket support.' +\n",
       "              'Please try Chrome, Safari or Firefox ≥ 6. ' +\n",
       "              'Firefox 4 and 5 are also supported but you ' +\n",
       "              'have to enable WebSockets in about:config.');\n",
       "    };\n",
       "}\n",
       "\n",
       "mpl.figure = function(figure_id, websocket, ondownload, parent_element) {\n",
       "    this.id = figure_id;\n",
       "\n",
       "    this.ws = websocket;\n",
       "\n",
       "    this.supports_binary = (this.ws.binaryType != undefined);\n",
       "\n",
       "    if (!this.supports_binary) {\n",
       "        var warnings = document.getElementById(\"mpl-warnings\");\n",
       "        if (warnings) {\n",
       "            warnings.style.display = 'block';\n",
       "            warnings.textContent = (\n",
       "                \"This browser does not support binary websocket messages. \" +\n",
       "                    \"Performance may be slow.\");\n",
       "        }\n",
       "    }\n",
       "\n",
       "    this.imageObj = new Image();\n",
       "\n",
       "    this.context = undefined;\n",
       "    this.message = undefined;\n",
       "    this.canvas = undefined;\n",
       "    this.rubberband_canvas = undefined;\n",
       "    this.rubberband_context = undefined;\n",
       "    this.format_dropdown = undefined;\n",
       "\n",
       "    this.image_mode = 'full';\n",
       "\n",
       "    this.root = $('<div/>');\n",
       "    this._root_extra_style(this.root)\n",
       "    this.root.attr('style', 'display: inline-block');\n",
       "\n",
       "    $(parent_element).append(this.root);\n",
       "\n",
       "    this._init_header(this);\n",
       "    this._init_canvas(this);\n",
       "    this._init_toolbar(this);\n",
       "\n",
       "    var fig = this;\n",
       "\n",
       "    this.waiting = false;\n",
       "\n",
       "    this.ws.onopen =  function () {\n",
       "            fig.send_message(\"supports_binary\", {value: fig.supports_binary});\n",
       "            fig.send_message(\"send_image_mode\", {});\n",
       "            if (mpl.ratio != 1) {\n",
       "                fig.send_message(\"set_dpi_ratio\", {'dpi_ratio': mpl.ratio});\n",
       "            }\n",
       "            fig.send_message(\"refresh\", {});\n",
       "        }\n",
       "\n",
       "    this.imageObj.onload = function() {\n",
       "            if (fig.image_mode == 'full') {\n",
       "                // Full images could contain transparency (where diff images\n",
       "                // almost always do), so we need to clear the canvas so that\n",
       "                // there is no ghosting.\n",
       "                fig.context.clearRect(0, 0, fig.canvas.width, fig.canvas.height);\n",
       "            }\n",
       "            fig.context.drawImage(fig.imageObj, 0, 0);\n",
       "        };\n",
       "\n",
       "    this.imageObj.onunload = function() {\n",
       "        fig.ws.close();\n",
       "    }\n",
       "\n",
       "    this.ws.onmessage = this._make_on_message_function(this);\n",
       "\n",
       "    this.ondownload = ondownload;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_header = function() {\n",
       "    var titlebar = $(\n",
       "        '<div class=\"ui-dialog-titlebar ui-widget-header ui-corner-all ' +\n",
       "        'ui-helper-clearfix\"/>');\n",
       "    var titletext = $(\n",
       "        '<div class=\"ui-dialog-title\" style=\"width: 100%; ' +\n",
       "        'text-align: center; padding: 3px;\"/>');\n",
       "    titlebar.append(titletext)\n",
       "    this.root.append(titlebar);\n",
       "    this.header = titletext[0];\n",
       "}\n",
       "\n",
       "\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function(canvas_div) {\n",
       "\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function(canvas_div) {\n",
       "\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_canvas = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var canvas_div = $('<div/>');\n",
       "\n",
       "    canvas_div.attr('style', 'position: relative; clear: both; outline: 0');\n",
       "\n",
       "    function canvas_keyboard_event(event) {\n",
       "        return fig.key_event(event, event['data']);\n",
       "    }\n",
       "\n",
       "    canvas_div.keydown('key_press', canvas_keyboard_event);\n",
       "    canvas_div.keyup('key_release', canvas_keyboard_event);\n",
       "    this.canvas_div = canvas_div\n",
       "    this._canvas_extra_style(canvas_div)\n",
       "    this.root.append(canvas_div);\n",
       "\n",
       "    var canvas = $('<canvas/>');\n",
       "    canvas.addClass('mpl-canvas');\n",
       "    canvas.attr('style', \"left: 0; top: 0; z-index: 0; outline: 0\")\n",
       "\n",
       "    this.canvas = canvas[0];\n",
       "    this.context = canvas[0].getContext(\"2d\");\n",
       "\n",
       "    var backingStore = this.context.backingStorePixelRatio ||\n",
       "\tthis.context.webkitBackingStorePixelRatio ||\n",
       "\tthis.context.mozBackingStorePixelRatio ||\n",
       "\tthis.context.msBackingStorePixelRatio ||\n",
       "\tthis.context.oBackingStorePixelRatio ||\n",
       "\tthis.context.backingStorePixelRatio || 1;\n",
       "\n",
       "    mpl.ratio = (window.devicePixelRatio || 1) / backingStore;\n",
       "\n",
       "    var rubberband = $('<canvas/>');\n",
       "    rubberband.attr('style', \"position: absolute; left: 0; top: 0; z-index: 1;\")\n",
       "\n",
       "    var pass_mouse_events = true;\n",
       "\n",
       "    canvas_div.resizable({\n",
       "        start: function(event, ui) {\n",
       "            pass_mouse_events = false;\n",
       "        },\n",
       "        resize: function(event, ui) {\n",
       "            fig.request_resize(ui.size.width, ui.size.height);\n",
       "        },\n",
       "        stop: function(event, ui) {\n",
       "            pass_mouse_events = true;\n",
       "            fig.request_resize(ui.size.width, ui.size.height);\n",
       "        },\n",
       "    });\n",
       "\n",
       "    function mouse_event_fn(event) {\n",
       "        if (pass_mouse_events)\n",
       "            return fig.mouse_event(event, event['data']);\n",
       "    }\n",
       "\n",
       "    rubberband.mousedown('button_press', mouse_event_fn);\n",
       "    rubberband.mouseup('button_release', mouse_event_fn);\n",
       "    // Throttle sequential mouse events to 1 every 20ms.\n",
       "    rubberband.mousemove('motion_notify', mouse_event_fn);\n",
       "\n",
       "    rubberband.mouseenter('figure_enter', mouse_event_fn);\n",
       "    rubberband.mouseleave('figure_leave', mouse_event_fn);\n",
       "\n",
       "    canvas_div.on(\"wheel\", function (event) {\n",
       "        event = event.originalEvent;\n",
       "        event['data'] = 'scroll'\n",
       "        if (event.deltaY < 0) {\n",
       "            event.step = 1;\n",
       "        } else {\n",
       "            event.step = -1;\n",
       "        }\n",
       "        mouse_event_fn(event);\n",
       "    });\n",
       "\n",
       "    canvas_div.append(canvas);\n",
       "    canvas_div.append(rubberband);\n",
       "\n",
       "    this.rubberband = rubberband;\n",
       "    this.rubberband_canvas = rubberband[0];\n",
       "    this.rubberband_context = rubberband[0].getContext(\"2d\");\n",
       "    this.rubberband_context.strokeStyle = \"#000000\";\n",
       "\n",
       "    this._resize_canvas = function(width, height) {\n",
       "        // Keep the size of the canvas, canvas container, and rubber band\n",
       "        // canvas in synch.\n",
       "        canvas_div.css('width', width)\n",
       "        canvas_div.css('height', height)\n",
       "\n",
       "        canvas.attr('width', width * mpl.ratio);\n",
       "        canvas.attr('height', height * mpl.ratio);\n",
       "        canvas.attr('style', 'width: ' + width + 'px; height: ' + height + 'px;');\n",
       "\n",
       "        rubberband.attr('width', width);\n",
       "        rubberband.attr('height', height);\n",
       "    }\n",
       "\n",
       "    // Set the figure to an initial 600x600px, this will subsequently be updated\n",
       "    // upon first draw.\n",
       "    this._resize_canvas(600, 600);\n",
       "\n",
       "    // Disable right mouse context menu.\n",
       "    $(this.rubberband_canvas).bind(\"contextmenu\",function(e){\n",
       "        return false;\n",
       "    });\n",
       "\n",
       "    function set_focus () {\n",
       "        canvas.focus();\n",
       "        canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    window.setTimeout(set_focus, 100);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var nav_element = $('<div/>')\n",
       "    nav_element.attr('style', 'width: 100%');\n",
       "    this.root.append(nav_element);\n",
       "\n",
       "    // Define a callback function for later on.\n",
       "    function toolbar_event(event) {\n",
       "        return fig.toolbar_button_onclick(event['data']);\n",
       "    }\n",
       "    function toolbar_mouse_event(event) {\n",
       "        return fig.toolbar_button_onmouseover(event['data']);\n",
       "    }\n",
       "\n",
       "    for(var toolbar_ind in mpl.toolbar_items) {\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) {\n",
       "            // put a spacer in here.\n",
       "            continue;\n",
       "        }\n",
       "        var button = $('<button/>');\n",
       "        button.addClass('ui-button ui-widget ui-state-default ui-corner-all ' +\n",
       "                        'ui-button-icon-only');\n",
       "        button.attr('role', 'button');\n",
       "        button.attr('aria-disabled', 'false');\n",
       "        button.click(method_name, toolbar_event);\n",
       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
       "\n",
       "        var icon_img = $('<span/>');\n",
       "        icon_img.addClass('ui-button-icon-primary ui-icon');\n",
       "        icon_img.addClass(image);\n",
       "        icon_img.addClass('ui-corner-all');\n",
       "\n",
       "        var tooltip_span = $('<span/>');\n",
       "        tooltip_span.addClass('ui-button-text');\n",
       "        tooltip_span.html(tooltip);\n",
       "\n",
       "        button.append(icon_img);\n",
       "        button.append(tooltip_span);\n",
       "\n",
       "        nav_element.append(button);\n",
       "    }\n",
       "\n",
       "    var fmt_picker_span = $('<span/>');\n",
       "\n",
       "    var fmt_picker = $('<select/>');\n",
       "    fmt_picker.addClass('mpl-toolbar-option ui-widget ui-widget-content');\n",
       "    fmt_picker_span.append(fmt_picker);\n",
       "    nav_element.append(fmt_picker_span);\n",
       "    this.format_dropdown = fmt_picker[0];\n",
       "\n",
       "    for (var ind in mpl.extensions) {\n",
       "        var fmt = mpl.extensions[ind];\n",
       "        var option = $(\n",
       "            '<option/>', {selected: fmt === mpl.default_extension}).html(fmt);\n",
       "        fmt_picker.append(option)\n",
       "    }\n",
       "\n",
       "    // Add hover states to the ui-buttons\n",
       "    $( \".ui-button\" ).hover(\n",
       "        function() { $(this).addClass(\"ui-state-hover\");},\n",
       "        function() { $(this).removeClass(\"ui-state-hover\");}\n",
       "    );\n",
       "\n",
       "    var status_bar = $('<span class=\"mpl-message\"/>');\n",
       "    nav_element.append(status_bar);\n",
       "    this.message = status_bar[0];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.request_resize = function(x_pixels, y_pixels) {\n",
       "    // Request matplotlib to resize the figure. Matplotlib will then trigger a resize in the client,\n",
       "    // which will in turn request a refresh of the image.\n",
       "    this.send_message('resize', {'width': x_pixels, 'height': y_pixels});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.send_message = function(type, properties) {\n",
       "    properties['type'] = type;\n",
       "    properties['figure_id'] = this.id;\n",
       "    this.ws.send(JSON.stringify(properties));\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.send_draw_message = function() {\n",
       "    if (!this.waiting) {\n",
       "        this.waiting = true;\n",
       "        this.ws.send(JSON.stringify({type: \"draw\", figure_id: this.id}));\n",
       "    }\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
       "    var format_dropdown = fig.format_dropdown;\n",
       "    var format = format_dropdown.options[format_dropdown.selectedIndex].value;\n",
       "    fig.ondownload(fig, format);\n",
       "}\n",
       "\n",
       "\n",
       "mpl.figure.prototype.handle_resize = function(fig, msg) {\n",
       "    var size = msg['size'];\n",
       "    if (size[0] != fig.canvas.width || size[1] != fig.canvas.height) {\n",
       "        fig._resize_canvas(size[0], size[1]);\n",
       "        fig.send_message(\"refresh\", {});\n",
       "    };\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_rubberband = function(fig, msg) {\n",
       "    var x0 = msg['x0'] / mpl.ratio;\n",
       "    var y0 = (fig.canvas.height - msg['y0']) / mpl.ratio;\n",
       "    var x1 = msg['x1'] / mpl.ratio;\n",
       "    var y1 = (fig.canvas.height - msg['y1']) / mpl.ratio;\n",
       "    x0 = Math.floor(x0) + 0.5;\n",
       "    y0 = Math.floor(y0) + 0.5;\n",
       "    x1 = Math.floor(x1) + 0.5;\n",
       "    y1 = Math.floor(y1) + 0.5;\n",
       "    var min_x = Math.min(x0, x1);\n",
       "    var min_y = Math.min(y0, y1);\n",
       "    var width = Math.abs(x1 - x0);\n",
       "    var height = Math.abs(y1 - y0);\n",
       "\n",
       "    fig.rubberband_context.clearRect(\n",
       "        0, 0, fig.canvas.width, fig.canvas.height);\n",
       "\n",
       "    fig.rubberband_context.strokeRect(min_x, min_y, width, height);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_figure_label = function(fig, msg) {\n",
       "    // Updates the figure title.\n",
       "    fig.header.textContent = msg['label'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_cursor = function(fig, msg) {\n",
       "    var cursor = msg['cursor'];\n",
       "    switch(cursor)\n",
       "    {\n",
       "    case 0:\n",
       "        cursor = 'pointer';\n",
       "        break;\n",
       "    case 1:\n",
       "        cursor = 'default';\n",
       "        break;\n",
       "    case 2:\n",
       "        cursor = 'crosshair';\n",
       "        break;\n",
       "    case 3:\n",
       "        cursor = 'move';\n",
       "        break;\n",
       "    }\n",
       "    fig.rubberband_canvas.style.cursor = cursor;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_message = function(fig, msg) {\n",
       "    fig.message.textContent = msg['message'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_draw = function(fig, msg) {\n",
       "    // Request the server to send over a new figure.\n",
       "    fig.send_draw_message();\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_image_mode = function(fig, msg) {\n",
       "    fig.image_mode = msg['mode'];\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function() {\n",
       "    // Called whenever the canvas gets updated.\n",
       "    this.send_message(\"ack\", {});\n",
       "}\n",
       "\n",
       "// A function to construct a web socket function for onmessage handling.\n",
       "// Called in the figure constructor.\n",
       "mpl.figure.prototype._make_on_message_function = function(fig) {\n",
       "    return function socket_on_message(evt) {\n",
       "        if (evt.data instanceof Blob) {\n",
       "            /* FIXME: We get \"Resource interpreted as Image but\n",
       "             * transferred with MIME type text/plain:\" errors on\n",
       "             * Chrome.  But how to set the MIME type?  It doesn't seem\n",
       "             * to be part of the websocket stream */\n",
       "            evt.data.type = \"image/png\";\n",
       "\n",
       "            /* Free the memory for the previous frames */\n",
       "            if (fig.imageObj.src) {\n",
       "                (window.URL || window.webkitURL).revokeObjectURL(\n",
       "                    fig.imageObj.src);\n",
       "            }\n",
       "\n",
       "            fig.imageObj.src = (window.URL || window.webkitURL).createObjectURL(\n",
       "                evt.data);\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "        else if (typeof evt.data === 'string' && evt.data.slice(0, 21) == \"data:image/png;base64\") {\n",
       "            fig.imageObj.src = evt.data;\n",
       "            fig.updated_canvas_event();\n",
       "            fig.waiting = false;\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        var msg = JSON.parse(evt.data);\n",
       "        var msg_type = msg['type'];\n",
       "\n",
       "        // Call the  \"handle_{type}\" callback, which takes\n",
       "        // the figure and JSON message as its only arguments.\n",
       "        try {\n",
       "            var callback = fig[\"handle_\" + msg_type];\n",
       "        } catch (e) {\n",
       "            console.log(\"No handler for the '\" + msg_type + \"' message type: \", msg);\n",
       "            return;\n",
       "        }\n",
       "\n",
       "        if (callback) {\n",
       "            try {\n",
       "                // console.log(\"Handling '\" + msg_type + \"' message: \", msg);\n",
       "                callback(fig, msg);\n",
       "            } catch (e) {\n",
       "                console.log(\"Exception inside the 'handler_\" + msg_type + \"' callback:\", e, e.stack, msg);\n",
       "            }\n",
       "        }\n",
       "    };\n",
       "}\n",
       "\n",
       "// from http://stackoverflow.com/questions/1114465/getting-mouse-location-in-canvas\n",
       "mpl.findpos = function(e) {\n",
       "    //this section is from http://www.quirksmode.org/js/events_properties.html\n",
       "    var targ;\n",
       "    if (!e)\n",
       "        e = window.event;\n",
       "    if (e.target)\n",
       "        targ = e.target;\n",
       "    else if (e.srcElement)\n",
       "        targ = e.srcElement;\n",
       "    if (targ.nodeType == 3) // defeat Safari bug\n",
       "        targ = targ.parentNode;\n",
       "\n",
       "    // jQuery normalizes the pageX and pageY\n",
       "    // pageX,Y are the mouse positions relative to the document\n",
       "    // offset() returns the position of the element relative to the document\n",
       "    var x = e.pageX - $(targ).offset().left;\n",
       "    var y = e.pageY - $(targ).offset().top;\n",
       "\n",
       "    return {\"x\": x, \"y\": y};\n",
       "};\n",
       "\n",
       "/*\n",
       " * return a copy of an object with only non-object keys\n",
       " * we need this to avoid circular references\n",
       " * http://stackoverflow.com/a/24161582/3208463\n",
       " */\n",
       "function simpleKeys (original) {\n",
       "  return Object.keys(original).reduce(function (obj, key) {\n",
       "    if (typeof original[key] !== 'object')\n",
       "        obj[key] = original[key]\n",
       "    return obj;\n",
       "  }, {});\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.mouse_event = function(event, name) {\n",
       "    var canvas_pos = mpl.findpos(event)\n",
       "\n",
       "    if (name === 'button_press')\n",
       "    {\n",
       "        this.canvas.focus();\n",
       "        this.canvas_div.focus();\n",
       "    }\n",
       "\n",
       "    var x = canvas_pos.x * mpl.ratio;\n",
       "    var y = canvas_pos.y * mpl.ratio;\n",
       "\n",
       "    this.send_message(name, {x: x, y: y, button: event.button,\n",
       "                             step: event.step,\n",
       "                             guiEvent: simpleKeys(event)});\n",
       "\n",
       "    /* This prevents the web browser from automatically changing to\n",
       "     * the text insertion cursor when the button is pressed.  We want\n",
       "     * to control all of the cursor setting manually through the\n",
       "     * 'cursor' event from matplotlib */\n",
       "    event.preventDefault();\n",
       "    return false;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
       "    // Handle any extra behaviour associated with a key event\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.key_event = function(event, name) {\n",
       "\n",
       "    // Prevent repeat events\n",
       "    if (name == 'key_press')\n",
       "    {\n",
       "        if (event.which === this._key)\n",
       "            return;\n",
       "        else\n",
       "            this._key = event.which;\n",
       "    }\n",
       "    if (name == 'key_release')\n",
       "        this._key = null;\n",
       "\n",
       "    var value = '';\n",
       "    if (event.ctrlKey && event.which != 17)\n",
       "        value += \"ctrl+\";\n",
       "    if (event.altKey && event.which != 18)\n",
       "        value += \"alt+\";\n",
       "    if (event.shiftKey && event.which != 16)\n",
       "        value += \"shift+\";\n",
       "\n",
       "    value += 'k';\n",
       "    value += event.which.toString();\n",
       "\n",
       "    this._key_event_extra(event, name);\n",
       "\n",
       "    this.send_message(name, {key: value,\n",
       "                             guiEvent: simpleKeys(event)});\n",
       "    return false;\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onclick = function(name) {\n",
       "    if (name == 'download') {\n",
       "        this.handle_save(this, null);\n",
       "    } else {\n",
       "        this.send_message(\"toolbar_button\", {name: name});\n",
       "    }\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.toolbar_button_onmouseover = function(tooltip) {\n",
       "    this.message.textContent = tooltip;\n",
       "};\n",
       "mpl.toolbar_items = [[\"Home\", \"Reset original view\", \"fa fa-home icon-home\", \"home\"], [\"Back\", \"Back to previous view\", \"fa fa-arrow-left icon-arrow-left\", \"back\"], [\"Forward\", \"Forward to next view\", \"fa fa-arrow-right icon-arrow-right\", \"forward\"], [\"\", \"\", \"\", \"\"], [\"Pan\", \"Pan axes with left mouse, zoom with right\", \"fa fa-arrows icon-move\", \"pan\"], [\"Zoom\", \"Zoom to rectangle\", \"fa fa-square-o icon-check-empty\", \"zoom\"], [\"\", \"\", \"\", \"\"], [\"Download\", \"Download plot\", \"fa fa-floppy-o icon-save\", \"download\"]];\n",
       "\n",
       "mpl.extensions = [\"eps\", \"pdf\", \"png\", \"ps\", \"raw\", \"svg\"];\n",
       "\n",
       "mpl.default_extension = \"png\";var comm_websocket_adapter = function(comm) {\n",
       "    // Create a \"websocket\"-like object which calls the given IPython comm\n",
       "    // object with the appropriate methods. Currently this is a non binary\n",
       "    // socket, so there is still some room for performance tuning.\n",
       "    var ws = {};\n",
       "\n",
       "    ws.close = function() {\n",
       "        comm.close()\n",
       "    };\n",
       "    ws.send = function(m) {\n",
       "        //console.log('sending', m);\n",
       "        comm.send(m);\n",
       "    };\n",
       "    // Register the callback with on_msg.\n",
       "    comm.on_msg(function(msg) {\n",
       "        //console.log('receiving', msg['content']['data'], msg);\n",
       "        // Pass the mpl event to the overridden (by mpl) onmessage function.\n",
       "        ws.onmessage(msg['content']['data'])\n",
       "    });\n",
       "    return ws;\n",
       "}\n",
       "\n",
       "mpl.mpl_figure_comm = function(comm, msg) {\n",
       "    // This is the function which gets called when the mpl process\n",
       "    // starts-up an IPython Comm through the \"matplotlib\" channel.\n",
       "\n",
       "    var id = msg.content.data.id;\n",
       "    // Get hold of the div created by the display call when the Comm\n",
       "    // socket was opened in Python.\n",
       "    var element = $(\"#\" + id);\n",
       "    var ws_proxy = comm_websocket_adapter(comm)\n",
       "\n",
       "    function ondownload(figure, format) {\n",
       "        window.open(figure.imageObj.src);\n",
       "    }\n",
       "\n",
       "    var fig = new mpl.figure(id, ws_proxy,\n",
       "                           ondownload,\n",
       "                           element.get(0));\n",
       "\n",
       "    // Call onopen now - mpl needs it, as it is assuming we've passed it a real\n",
       "    // web socket which is closed, not our websocket->open comm proxy.\n",
       "    ws_proxy.onopen();\n",
       "\n",
       "    fig.parent_element = element.get(0);\n",
       "    fig.cell_info = mpl.find_output_cell(\"<div id='\" + id + \"'></div>\");\n",
       "    if (!fig.cell_info) {\n",
       "        console.error(\"Failed to find cell for figure\", id, fig);\n",
       "        return;\n",
       "    }\n",
       "\n",
       "    var output_index = fig.cell_info[2]\n",
       "    var cell = fig.cell_info[0];\n",
       "\n",
       "};\n",
       "\n",
       "mpl.figure.prototype.handle_close = function(fig, msg) {\n",
       "    var width = fig.canvas.width/mpl.ratio\n",
       "    fig.root.unbind('remove')\n",
       "\n",
       "    // Update the output cell to use the data from the current canvas.\n",
       "    fig.push_to_output();\n",
       "    var dataURL = fig.canvas.toDataURL();\n",
       "    // Re-enable the keyboard manager in IPython - without this line, in FF,\n",
       "    // the notebook keyboard shortcuts fail.\n",
       "    IPython.keyboard_manager.enable()\n",
       "    $(fig.parent_element).html('<img src=\"' + dataURL + '\" width=\"' + width + '\">');\n",
       "    fig.close_ws(fig, msg);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.close_ws = function(fig, msg){\n",
       "    fig.send_message('closing', msg);\n",
       "    // fig.ws.close()\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.push_to_output = function(remove_interactive) {\n",
       "    // Turn the data on the canvas into data in the output cell.\n",
       "    var width = this.canvas.width/mpl.ratio\n",
       "    var dataURL = this.canvas.toDataURL();\n",
       "    this.cell_info[1]['text/html'] = '<img src=\"' + dataURL + '\" width=\"' + width + '\">';\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.updated_canvas_event = function() {\n",
       "    // Tell IPython that the notebook contents must change.\n",
       "    IPython.notebook.set_dirty(true);\n",
       "    this.send_message(\"ack\", {});\n",
       "    var fig = this;\n",
       "    // Wait a second, then push the new image to the DOM so\n",
       "    // that it is saved nicely (might be nice to debounce this).\n",
       "    setTimeout(function () { fig.push_to_output() }, 1000);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._init_toolbar = function() {\n",
       "    var fig = this;\n",
       "\n",
       "    var nav_element = $('<div/>')\n",
       "    nav_element.attr('style', 'width: 100%');\n",
       "    this.root.append(nav_element);\n",
       "\n",
       "    // Define a callback function for later on.\n",
       "    function toolbar_event(event) {\n",
       "        return fig.toolbar_button_onclick(event['data']);\n",
       "    }\n",
       "    function toolbar_mouse_event(event) {\n",
       "        return fig.toolbar_button_onmouseover(event['data']);\n",
       "    }\n",
       "\n",
       "    for(var toolbar_ind in mpl.toolbar_items){\n",
       "        var name = mpl.toolbar_items[toolbar_ind][0];\n",
       "        var tooltip = mpl.toolbar_items[toolbar_ind][1];\n",
       "        var image = mpl.toolbar_items[toolbar_ind][2];\n",
       "        var method_name = mpl.toolbar_items[toolbar_ind][3];\n",
       "\n",
       "        if (!name) { continue; };\n",
       "\n",
       "        var button = $('<button class=\"btn btn-default\" href=\"#\" title=\"' + name + '\"><i class=\"fa ' + image + ' fa-lg\"></i></button>');\n",
       "        button.click(method_name, toolbar_event);\n",
       "        button.mouseover(tooltip, toolbar_mouse_event);\n",
       "        nav_element.append(button);\n",
       "    }\n",
       "\n",
       "    // Add the status bar.\n",
       "    var status_bar = $('<span class=\"mpl-message\" style=\"text-align:right; float: right;\"/>');\n",
       "    nav_element.append(status_bar);\n",
       "    this.message = status_bar[0];\n",
       "\n",
       "    // Add the close button to the window.\n",
       "    var buttongrp = $('<div class=\"btn-group inline pull-right\"></div>');\n",
       "    var button = $('<button class=\"btn btn-mini btn-primary\" href=\"#\" title=\"Stop Interaction\"><i class=\"fa fa-power-off icon-remove icon-large\"></i></button>');\n",
       "    button.click(function (evt) { fig.handle_close(fig, {}); } );\n",
       "    button.mouseover('Stop Interaction', toolbar_mouse_event);\n",
       "    buttongrp.append(button);\n",
       "    var titlebar = this.root.find($('.ui-dialog-titlebar'));\n",
       "    titlebar.prepend(buttongrp);\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._root_extra_style = function(el){\n",
       "    var fig = this\n",
       "    el.on(\"remove\", function(){\n",
       "\tfig.close_ws(fig, {});\n",
       "    });\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._canvas_extra_style = function(el){\n",
       "    // this is important to make the div 'focusable\n",
       "    el.attr('tabindex', 0)\n",
       "    // reach out to IPython and tell the keyboard manager to turn it's self\n",
       "    // off when our div gets focus\n",
       "\n",
       "    // location in version 3\n",
       "    if (IPython.notebook.keyboard_manager) {\n",
       "        IPython.notebook.keyboard_manager.register_events(el);\n",
       "    }\n",
       "    else {\n",
       "        // location in version 2\n",
       "        IPython.keyboard_manager.register_events(el);\n",
       "    }\n",
       "\n",
       "}\n",
       "\n",
       "mpl.figure.prototype._key_event_extra = function(event, name) {\n",
       "    var manager = IPython.notebook.keyboard_manager;\n",
       "    if (!manager)\n",
       "        manager = IPython.keyboard_manager;\n",
       "\n",
       "    // Check for shift+enter\n",
       "    if (event.shiftKey && event.which == 13) {\n",
       "        this.canvas_div.blur();\n",
       "        event.shiftKey = false;\n",
       "        // Send a \"J\" for go to next cell\n",
       "        event.which = 74;\n",
       "        event.keyCode = 74;\n",
       "        manager.command_mode();\n",
       "        manager.handle_keydown(event);\n",
       "    }\n",
       "}\n",
       "\n",
       "mpl.figure.prototype.handle_save = function(fig, msg) {\n",
       "    fig.ondownload(fig, null);\n",
       "}\n",
       "\n",
       "\n",
       "mpl.find_output_cell = function(html_output) {\n",
       "    // Return the cell and output element which can be found *uniquely* in the notebook.\n",
       "    // Note - this is a bit hacky, but it is done because the \"notebook_saving.Notebook\"\n",
       "    // IPython event is triggered only after the cells have been serialised, which for\n",
       "    // our purposes (turning an active figure into a static one), is too late.\n",
       "    var cells = IPython.notebook.get_cells();\n",
       "    var ncells = cells.length;\n",
       "    for (var i=0; i<ncells; i++) {\n",
       "        var cell = cells[i];\n",
       "        if (cell.cell_type === 'code'){\n",
       "            for (var j=0; j<cell.output_area.outputs.length; j++) {\n",
       "                var data = cell.output_area.outputs[j];\n",
       "                if (data.data) {\n",
       "                    // IPython >= 3 moved mimebundle to data attribute of output\n",
       "                    data = data.data;\n",
       "                }\n",
       "                if (data['text/html'] == html_output) {\n",
       "                    return [cell, data, j];\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    }\n",
       "}\n",
       "\n",
       "// Register the function which deals with the matplotlib target/channel.\n",
       "// The kernel may be null if the page has been refreshed.\n",
       "if (IPython.notebook.kernel != null) {\n",
       "    IPython.notebook.kernel.comm_manager.register_target('matplotlib', mpl.mpl_figure_comm);\n",
       "}\n"
      ],
      "text/plain": [
       "<IPython.core.display.Javascript object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "text/html": [
       "<img src=\"\" width=\"400\">"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "hat_xs, zlist = read_data()  ###graphbasedslam3exec\n",
    "edges = make_edges(hat_xs, zlist)\n",
    "draw(hat_xs, zlist, edges)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
